package cn.tedu.file;

import java.io.*;

/**本类用于字节输入流*/
public class TestIn {
    public static void main(String[] args) {
//        method1();//普通字节输入流
        method2();//高效字节输入流
    }

    private static void method2() {
        BufferedInputStream in = null;
        try {
//            BufferedInputStream in2 = new BufferedInputStream(new FileInputStream(new File("C:\\kaifa\\ready\\1.txt")));
            in = new BufferedInputStream(new FileInputStream("C:\\kaifa\\ready\\1.txt"));
            int b ;
            while ((b = in.read())!=-1){
                System.out.println(b);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }

    private static void method1() {
        FileInputStream in = null;
        try {
//            FileInputStream in2 = new FileInputStream(new File("C:\\kaifa\\ready\\1.txt"));
            in = new FileInputStream("C:\\kaifa\\ready\\1.txt");
            int b;
            while((b = in.read())!=-1){
                System.out.println(b);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }finally {
            try {
                in.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
